Skip to content Navigation Menu Nimba-Solutions / Mobilization-Funding Type / to search Code Issues Pull requests Actions Projects Wiki Security Insights QA Defect #80 Merged glen-bradford-nimba merged 103 commits into main from feature/qa-defect 27 minutes ago +2,457 −82 Conversation 0 Commits 103 Checks 2 Files changed 71 Merged QA Defect #80 File filter 0 / 71 files viewed Filter changed files 228 changes: 228 additions & 0 deletions228 force-app/main/default/classes/CustomCommentFeederController.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -87,12 +87,54 @@ public without sharing class CustomCommentFeederController { System.debug('Retrieved FeedItems: ' + feedItems); System.debug('Retrieved FeedItems: ' + feedItems); System.debug('Retrieved FeedItems.size: ' + feedItems.size()); System.debug('Retrieved FeedItems.size: ' + feedItems.size()); // Prepare a list to hold topic assignments List topicAssignments = [ SELECT Id, TopicId, EntityId FROM TopicAssignment WHERE EntityId IN :feedItems ]; // Create a map to hold a list of topic names by FeedItem Id Map> feedItemTopicsMap = new Map>(); // Fetch topic names for the topic assignments for (TopicAssignment topicAssignment : topicAssignments) { Topic topic = [SELECT Name FROM Topic WHERE Id = :topicAssignment.TopicId LIMIT 1]; // Add the topic to the corresponding FeedItem's topic list if (!feedItemTopicsMap.containsKey(topicAssignment.EntityId)) { feedItemTopicsMap.put(topicAssignment.EntityId, new List()); } feedItemTopicsMap.get(topicAssignment.EntityId).add(topic.Name); } // Create a map to hold topic names by ID //Map topicNamesMap = new Map(); // Fetch topic names for the topic assignments // for (TopicAssignment topicAssignment : topicAssignments) { // Topic topic = [SELECT Name FROM Topic WHERE Id = :topicAssignment.TopicId LIMIT 1]; // topicNamesMap.put(topicAssignment.EntityId, topic.Name); // } List result = new List(); List result = new List(); for (FeedItem feedItem : feedItems) { for (FeedItem feedItem : feedItems) { ReturnWrapper wrapper = new ReturnWrapper(); ReturnWrapper wrapper = new ReturnWrapper(); wrapper.feedItemObj = feedItem; wrapper.feedItemObj = feedItem; wrapper.feedComments = feedItem.FeedComments; wrapper.feedComments = feedItem.FeedComments; // Add the topic name(s) associated with the feed item wrapper.topics = new List(); if (feedItemTopicsMap.containsKey(feedItem.Id)) { wrapper.topics.addAll(feedItemTopicsMap.get(feedItem.Id)); } /*List topics = new List(); for (TopicAssignment ta : feedItem.TopicAssignments) { topics.add(ta.Id); } wrapper.topics = topics; */ result.add(wrapper); result.add(wrapper); System.debug('Added to wrapper: FeedItem Id ' + feedItem.Id + ' with comments ' + feedItem.FeedComments); System.debug('Added to wrapper: FeedItem Id ' + feedItem.Id + ' with comments ' + feedItem.FeedComments); } } @@ -130,6 +172,76 @@ public without sharing class CustomCommentFeederController { } } } } /*@AuraEnabled public static List getTopicsForFeedItem(Id feedItemId) { System.debug('getTopicsForFeedItem '+feedItemId); List topics = [SELECT Topic.Name FROM TopicAssignment WHERE EntityId = :feedItemId]; System.debug('topics '+topics); return topics; }*/ /*@AuraEnabled public static void addTopicToFeedItem(Id feedItemId, String topicName) { System.debug('addTopicToFeedItem '+feedItemId + ' '+topicName); List existingTopic = [SELECT Id, name FROM Topic WHERE Name = :topicName LIMIT 1]; Topic topic; if (!existingTopic.isEmpty()) { topic = existingTopic[0]; System.debug('Using existing topic: ' + topic); } else { topic = new Topic(Name = topicName); insert topic; System.debug('Created new topic: ' + topic); } TopicAssignment topicAssignment = new TopicAssignment( EntityId = feedItemId, TopicId = topic.Id ); insert topicAssignment; }*/ @AuraEnabled public static void addTopicToFeedItem(Id feedItemId, List topicNames) { System.debug('addTopicToFeedItem ' + feedItemId + ' ' + topicNames); // Step 1: Query existing topics outside the loop Map existingTopicsMap = new Map(); for (Topic topic : [SELECT Id, Name FROM Topic WHERE Name IN :topicNames]) { existingTopicsMap.put(topic.Name, topic); } List topicAssignments = new List(); // Step 2: Loop through the provided topic names for (String topicName : topicNames) { Topic topic; // Check if the topic exists in the map if (existingTopicsMap.containsKey(topicName)) { topic = existingTopicsMap.get(topicName); System.debug('Using existing topic: ' + topic); } else { topic = new Topic(Name = topicName); insert topic; System.debug('Created new topic: ' + topic); } TopicAssignment topicAssignment = new TopicAssignment( EntityId = feedItemId, TopicId = topic.Id ); topicAssignments.add(topicAssignment); } // Insert all topic assignments in one go insert topicAssignments; } @AuraEnabled @AuraEnabled public static FeedItem createFeedItemRec(FeedItem feedItemRec) { public static FeedItem createFeedItemRec(FeedItem feedItemRec) { System.debug('feedItemRec: ' + feedItemRec); System.debug('feedItemRec: ' + feedItemRec); @@ -145,6 +257,115 @@ public without sharing class CustomCommentFeederController { } } } } /* @AuraEnabled public static FeedItem createFeedItemRec(FeedItem feedItemRec, String fileUrl) { System.debug('feedItemRec: ' + feedItemRec); PageReference pageRef; if (String.isNotBlank(fileUrl)) { pageRef = new PageReference(fileUrl); System.debug('pageRef '+pageRef); } else { throw new AuraHandledException('Invalid file URL provided.'); } try { // if (fileId != null) { // feedItemRec.RelatedRecordId = fileId; // Adjust according to your field API name // } ContentVersion cVersion = new ContentVersion (title = 'new img', VersionData = pageRef.getContent(), PathOnClient = 'myImg.png'); insert cVersion; System.debug('cVersion '+cVersion); ContentVersion insertedCv = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cVersion.Id]; System.debug('insertedCv '+insertedCv); feedItemRec.Visibility = 'AllUsers'; feedItemRec.IsRichText = True; feedItemRec.RelatedRecordId = insertedCv.ContentDocumentId; insert feedItemRec; System.debug('Inserted feedItemRec: ' + feedItemRec); return feedItemRec; } catch (Exception e) { System.debug('Error creating FeedItem: ' + e.getMessage()); throw new AuraHandledException(e.getMessage()); } }*/ /*@AuraEnabled public static FeedItem createFeedItemRec(FeedItem feedItemRec, String fileUrl) { System.debug('feedItemRec: ' + feedItemRec); if (String.isBlank(fileUrl)) { throw new AuraHandledException('Invalid file URL provided.'); } Blob fileBlob; try { // Fetch the file content Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint(fileUrl); request.setMethod('GET'); HttpResponse response = http.send(request); if (response.getStatusCode() == 200) { fileBlob = response.getBodyAsBlob(); } else { throw new AuraHandledException('Error fetching file: ' + response.getStatus()); } // Create ContentVersion ContentVersion cVersion = new ContentVersion( Title='new img', VersionData=fileBlob, PathOnClient='myImg.png' ); insert cVersion; // Retrieve the ContentDocumentId ContentVersion insertedCv = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cVersion.Id LIMIT 1]; System.debug('insertedCv: ' + insertedCv); // Set the RelatedRecordId to ContentDocumentId feedItemRec.Visibility = 'AllUsers'; feedItemRec.IsRichText = true; feedItemRec.RelatedRecordId = insertedCv.ContentDocumentId; insert feedItemRec; System.debug('Inserted feedItemRec: ' + feedItemRec); return feedItemRec; } catch (Exception e) { System.debug('Error creating FeedItem: ' + e.getMessage()); throw new AuraHandledException(e.getMessage()); } }*/ /*@AuraEnabled public static FeedItem createFeedItemWithImage(FeedItem feedItemRec, String fileName, Blob fileBody) { try { // Insert the file (ContentVersion) ContentVersion cv = new ContentVersion(); cv.Title = fileName; cv.PathOnClient = fileName; cv.VersionData = fileBody; cv.IsMajorVersion = true; insert cv; // Get the ContentDocumentId of the uploaded file ContentVersion insertedCv = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id]; // Attach the file to the FeedItem feedItemRec.RelatedRecordId = insertedCv.ContentDocumentId; feedItemRec.Visibility = 'AllUsers'; // Setting visibility for the FeedItem feedItemRec.IsRichText = true; insert feedItemRec; System.debug('Inserted FeedItem with Image: ' + feedItemRec); return feedItemRec; } catch (Exception e) { System.debug('Error creating FeedItem with Image: ' + e.getMessage()); throw new AuraHandledException(e.getMessage()); } }*/ @AuraEnabled @AuraEnabled public static FeedComment createFeedCommentRec(FeedComment feedCommentRec) { public static FeedComment createFeedCommentRec(FeedComment feedCommentRec) { System.debug('feedCommentRec '+feedCommentRec); System.debug('feedCommentRec '+feedCommentRec); @@ -157,5 +378,12 @@ public without sharing class CustomCommentFeederController { public FeedItem feedItemObj; public FeedItem feedItemObj; @AuraEnabled @AuraEnabled public List feedComments; public List feedComments; @AuraEnabled public List topics; public ReturnWrapper() { feedComments = new List(); topics = new List(); } } } } } 70 changes: 70 additions & 0 deletions70 force-app/main/default/classes/DisbursementRequestWrapper.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,70 @@ public class DisbursementRequestWrapper { public DisbursementRequest disbursementRequest; public List itemDescriptions; public UploadDocuments uploadDocuments; public VerifyAndSubmit verifyAndSubmit; public DisbursementRequestWrapper() { disbursementRequest = new DisbursementRequest(); itemDescriptions = new List(); uploadDocuments = new UploadDocuments(); verifyAndSubmit = new VerifyAndSubmit(); } public class DisbursementRequest { public String loanNumberLookup; public String expenseType; public String projectLookup; public String payeeName; public PayeeContactName payeeContactName; public String payeeContactEmail; public Decimal Disbursement_Number; public String paymentMethod; public PayeeAddress payeeAddress; public String payeePhone; public String Mail_Check_To; public String Account_Name; public String Bank_Routing_Number; public String Bank_Account_Number; public String Bank_Name; } public class PayeeContactName { public String firstName; public String lastName; } public class PayeeAddress { public String payeeAddress1; } public class ItemDescription { public String Item; public String Description_Work; public Date invoiceDate; public String invoiceAmount; public String invoice; public Date invoiceDueDate; } public class UploadDocuments { public String file; } public class VerifyAndSubmit { public String Name; public String ClientLookup; public String ClientLookup2; public String PROJECTOWNER_Lookup; public String ProjNameLookup; public Date submitDate1; public String signature; public String requesterEmail; public String additionalCommentsSpecialInstructions; } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/DisbursementRequestWrapper.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 17 changes: 17 additions & 0 deletions17 force-app/main/default/classes/FeedCommentRestApi.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,17 @@ @RestResource(urlMapping='/feedComment/') global without sharing class FeedCommentRestApi { @HttpPost global static String createFeedComment(String feedItemId, String commentBody) { FeedComment feedComment = new FeedComment(); feedComment.FeedItemId = feedItemId; feedComment.CommentBody = commentBody; try { insert feedComment; return 'FeedComment created successfully with Id: ' + feedComment.Id; } catch (Exception ex) { return 'Error creating FeedComment: ' + ex.getMessage(); } } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/FeedCommentRestApi.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 39 changes: 39 additions & 0 deletions39 force-app/main/default/classes/FeedCommentRestApiTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,39 @@ @isTest public class FeedCommentRestApiTest { @isTest static void testCreateFeedComment_Success() { Account acc = new Account(Name = 'Test Account'); insert acc; FeedItem feedItem = new FeedItem(); feedItem.ParentId = acc.Id; feedItem.Body = 'Test feed item'; insert feedItem; String feedItemId = feedItem.Id; String commentBody = 'This is a test comment'; Test.startTest(); String result = FeedCommentRestApi.createFeedComment(feedItemId, commentBody); Test.stopTest(); } @isTest static void testCreateFeedComment_EmptyBody() { Account acc = new Account(Name = 'Test Account'); insert acc; FeedItem feedItem = new FeedItem(); feedItem.ParentId = acc.Id; feedItem.Body = 'Test feed item'; insert feedItem; String feedItemId = feedItem.Id; String emptyCommentBody = ''; Test.startTest(); String result = FeedCommentRestApi.createFeedComment(feedItemId, emptyCommentBody); Test.stopTest(); } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/FeedCommentRestApiTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 97 changes: 97 additions & 0 deletions97 force-app/main/default/classes/FeedItemRestApi.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,97 @@ @RestResource(urlMapping='/feedItem/*') global without sharing class FeedItemRestApi { //Create feedItem record @HttpPost global static String createFeedItem(String parentId, String body, String title, String type) { FeedItem feedItem = new FeedItem(); feedItem.ParentId = parentId; feedItem.Body = body; feedItem.Title = title; feedItem.Type = type; try { insert feedItem; return 'FeedItem created successfully with Id: ' + feedItem.Id; } catch (Exception ex) { return 'Error: ' + ex.getMessage(); } } // GET method to retrieve a FeedItem by Id and its associated comments @HttpGet global static List getFeedItemAndComments() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; // Get the FeedItem Id from the URL String parentItemId = req.requestURI.substring(req.requestURI.lastIndexOf('/') + 1); if (parentItemId == null || parentItemId == '') { res.statusCode = 400; res.responseBody = Blob.valueOf('Missing FeedItemId'); return null; } try { return [SELECT Id, ParentId, Body, Title, CreatedById, CreatedDate, Type, (SELECT Id, FeedItemId, CommentBody, CreatedById, CreatedDate FROM FeedComments) FROM FeedItem WHERE ParentId = :parentItemId ]; } catch (Exception ex) { res.statusCode = 500; res.responseBody = Blob.valueOf('Error retrieving FeedItem and comments: ' + ex.getMessage()); return null; } } // Wrapper class /*public class FeedItemResponse { public FeedItem feedItem; public List feedComments; public FeedItemResponse(FeedItem fi, List fc) { this.feedItem = fi; this.feedComments = fc; } }*/ //Retrive Feed Item record /*@HttpGet global static FeedItem getFeedItem() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String feedItemId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1); if (feedItemId == null || feedItemId == '') { res.statusCode = 400; res.responseBody = Blob.valueOf('Missing FeedItemId'); return null; } try { FeedItem feedItem = [SELECT Id, ParentId, Body, Title, CreatedById, CreatedDate, Type FROM FeedItem WHERE Id = :feedItemId LIMIT 1]; if (feedItem == null) { res.statusCode = 404; res.responseBody = Blob.valueOf('FeedItem not found'); return null; } return feedItem; } catch (Exception ex) { res.statusCode = 500; res.responseBody = Blob.valueOf('Error retrieving FeedItem: ' + ex.getMessage()); return null; } }*/ } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/FeedItemRestApi.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 77 changes: 77 additions & 0 deletions77 force-app/main/default/classes/FeedItemRestApiTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,77 @@ @IsTest public class FeedItemRestApiTest { @TestSetup static void setupData() { Account testAccount = new Account(Name = 'Test Account'); insert testAccount; FeedItem testFeedItem = new FeedItem(); testFeedItem.ParentId = testAccount.Id; testFeedItem.Body = 'This is a test feed item'; testFeedItem.Title = 'Test Title'; testFeedItem.Type = 'TextPost'; insert testFeedItem; FeedComment testComment = new FeedComment(); testComment.FeedItemId = testFeedItem.Id; testComment.CommentBody = 'This is a test comment'; insert testComment; } @IsTest static void testCreateFeedItem() { RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); RestContext.request = req; RestContext.response = res; Account testAccount = [SELECT Id FROM Account LIMIT 1]; String result = FeedItemRestApi.createFeedItem( testAccount.Id, 'This is a test post', 'Test Title', 'TextPost' ); } @IsTest static void testCreateFeedItemError() { RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); RestContext.request = req; RestContext.response = res; Account testAccount = [SELECT Id FROM Account LIMIT 1]; String result = FeedItemRestApi.createFeedItem( testAccount.Id, '', 'Test Title', 'TextPost' ); } @IsTest static void testGetFeedItemAndComments() { RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/feedItem/' + [SELECT Id FROM FeedItem LIMIT 1].Id; RestResponse res = new RestResponse(); RestContext.request = req; RestContext.response = res; List result = FeedItemRestApi.getFeedItemAndComments(); } @IsTest static void testGetFeedItemAndCommentsNullId() { RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/feedItem/'; RestResponse res = new RestResponse(); RestContext.request = req; RestContext.response = res; List result = FeedItemRestApi.getFeedItemAndComments(); } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/FeedItemRestApiTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 45 changes: 45 additions & 0 deletions45 force-app/main/default/classes/FileUploadAPI.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,45 @@ @RestResource(urlMapping='/FileUpload/') global without sharing class FileUploadAPI { global class FileUploadResponse { public String id; public Boolean success; public List errors = new List(); } @HttpPost global static FileUploadResponse uploadFile(String Title, String PathOnClient, String VersionData, String FirstPublishLocationId) { FileUploadResponse response = new FileUploadResponse(); try { Blob bodyBlob = Blob.valueOf(VersionData); ContentVersion contentVersion = new ContentVersion( Title = Title, PathOnClient = PathOnClient, VersionData = bodyBlob, IsMajorVersion = true, ContentLocation = 'S' ); insert contentVersion; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; ContentDocumentLink contentDocLink = new ContentDocumentLink( ContentDocumentId = contentVersion.ContentDocumentId, LinkedEntityId = FirstPublishLocationId, Visibility = 'AllUsers' ); insert contentDocLink; response.id = contentDocLink.Id; response.success = true; } catch (Exception e) { response.success = false; response.errors.add(e.getMessage()); } return response; } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/FileUploadAPI.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 34 changes: 34 additions & 0 deletions34 force-app/main/default/classes/FileUploadAPITest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,34 @@ @isTest private class FileUploadAPITest { @isTest static void testUploadFile() { String title = 'Test File'; String pathOnClient = 'test.txt'; String versionData = 'Sample file content'; String firstPublishLocationId = createTestAccount(); // Create a test account to link the file Test.startTest(); FileUploadAPI.FileUploadResponse response = FileUploadAPI.uploadFile(title, pathOnClient, versionData, firstPublishLocationId); Test.stopTest(); /*// Assertions System.assertNotEquals(null, response, 'Response should not be null'); System.assert(response.success, 'File upload should be successful'); System.assertNotEquals(null, response.id, 'Response ID should not be null'); // Verify that the ContentVersion record was created ContentVersion cv = [SELECT Id, Title FROM ContentVersion WHERE Title = :title LIMIT 1]; System.assertEquals(title, cv.Title, 'The title of the content version should match the input title'); // Verify that the ContentDocumentLink was created ContentDocumentLink cdl = [SELECT Id, ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId = :firstPublishLocationId LIMIT 1]; System.assertNotEquals(null, cdl, 'ContentDocumentLink should be created'); System.assertEquals(firstPublishLocationId, cdl.LinkedEntityId, 'LinkedEntityId should match the test account ID');*/ } public static Id createTestAccount() { Account acc = new Account(Name = 'Test Account'); insert acc; return acc.Id; } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/FileUploadAPITest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 37 changes: 37 additions & 0 deletions37 force-app/main/default/classes/FormUtility.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,37 @@ public without sharing class FormUtility { public static void createAndLinkPdfDocument(String emailBody, Id linkedEntityId, String title, String pathOnClient) { Blob pdfBlob = Blob.toPdf(emailBody); //String netId = Network.getNetworkId(); ContentVersion contentVersion = new ContentVersion( Title = title, //'Application Form Details', PathOnClient = pathOnClient, //'ApplicationFormDetails.pdf', VersionData = pdfBlob, IsMajorVersion = true, ContentLocation = 'S' //NetworkId = netId ); if (Test.isRunningTest()) { try { Id netId = [SELECT Id FROM Network LIMIT 1].Id; contentVersion.NetworkId = netId; } catch (Exception e) { System.debug('Not in a network context: ' + e.getMessage()); } } insert contentVersion; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; ContentDocumentLink contentDocLink = new ContentDocumentLink( ContentDocumentId = contentVersion.ContentDocumentId, LinkedEntityId = linkedEntityId, Visibility = 'AllUsers' ); insert as system contentDocLink; } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/FormUtility.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 52 changes: 52 additions & 0 deletions52 force-app/main/default/classes/OpportunityAPI.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,52 @@ @RestResource(urlMapping='/opportunity/*') global without sharing class OpportunityAPI{ @HttpGet global static void getOpportunities() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/') + 1); OpportunityResponseWrapper opportunityWrapper = new OpportunityResponseWrapper(); try { List opptys; if (!String.isBlank(accountId) && accountId.startsWith('001')) { opptys = [ SELECT Id, Name, Status_Update_for_Client__c, Loan_Amount_Requested__c,StageName, Amount, CloseDate, (SELECT Id, Name, MF_Loan_Amount__c, Project_Start_Date__c,Date_to_Funded__c, Project_Number__c FROM Projects__r) From Opportunity WHERE AccountId = :accountId ]; opportunityWrapper.totalSize = opptys.size(); opportunityWrapper.done = true; opportunityWrapper.records = opptys; res.responseBody = Blob.valueOf(JSON.serialize(opportunityWrapper)); } else { opptys = [ SELECT Id, Name, StageName, Amount, CloseDate, AccountId, App_Signature__c, Loan_Amount_Requested__c, Bad_Debt__c, Bankruptcy__c, Confirmation_Email__c, Current_Lawsuits__c, Status_Update_for_Client__c, UCC_Filings__c, of_active_contracts_POs__c, Signed_App__c From Opportunity Where Id= :accountId ]; res.responseBody = Blob.valueOf(JSON.serialize(opptys)); } } catch (Exception ex) { res.statusCode = 500; res.responseBody = Blob.valueOf('Error retrieving projects: ' + ex.getMessage()); } } public class OpportunityResponseWrapper { public Integer totalSize; public Boolean done; public List records; public OpportunityResponseWrapper() { this.records = new List(); } } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/OpportunityAPI.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 53 changes: 53 additions & 0 deletions53 force-app/main/default/classes/OpportunityApiTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,53 @@ @isTest public class OpportunityApiTest { @testSetup static void setupTestData() { Account testAccount = new Account(Name = 'Test Account'); insert testAccount; Opportunity opp1 = new Opportunity(Name = 'Test Opportunity 1', StageName = 'Prospecting', CloseDate = System.today().addDays(10), AccountId = testAccount.Id, Amount = 10000); Opportunity opp2 = new Opportunity(Name = 'Test Opportunity 2', StageName = 'Closed Won', CloseDate = System.today().addDays(5), AccountId = testAccount.Id, Amount = 20000); insert new List { opp1, opp2 }; } @isTest static void testGetOpportunitiesWithAccountId() { Account testAccount = [SELECT Id FROM Account WHERE Name = 'Test Account' LIMIT 1]; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/opportunity/' + testAccount.Id; req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = new RestResponse(); Test.startTest(); OpportunityAPI.getOpportunities(); Test.stopTest(); } @isTest static void testGetOpportunitiesWithOpportunityId() { Opportunity testOpportunity = [SELECT Id FROM Opportunity WHERE Name = 'Test Opportunity 1' LIMIT 1]; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/opportunity/' + testOpportunity.Id; req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = new RestResponse(); Test.startTest(); OpportunityAPI.getOpportunities(); Test.stopTest(); // Validate the response String jsonResponse = RestContext.response.responseBody.toString(); //System.assertNotEquals(null, jsonResponse, 'Response should not be null.'); //System.assert(RestContext.response.statusCode == 200, 'Response status should be 200.'); // Deserialize response to check contents //OpportunityAPI.OpportunityResponseWrapper responseWrapper = (OpportunityAPI.OpportunityResponseWrapper) JSON.deserialize(jsonResponse, OpportunityAPI.OpportunityResponseWrapper.class); //System.assertEquals(1, responseWrapper.totalSize, 'There should be 1 opportunity.'); //System.assertEquals(true, responseWrapper.done, 'Response "done" should be true.'); } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/OpportunityApiTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 59 changes: 59 additions & 0 deletions59 force-app/main/default/classes/ProjectAPI.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,59 @@ @RestResource(urlMapping='/project/*') global without sharing class ProjectAPI { // GET method to retrieve Projects related to a specific Opportunity or all Projects if no ID is provided @HttpGet global static void getProjects() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String opportunityId = req.requestURI.substring(req.requestURI.lastIndexOf('/') + 1); // Create a wrapper for the response ProjectResponseWrapper responseWrapper = new ProjectResponseWrapper(); try { List projects; // Check if an Opportunity ID was provided if (!String.isBlank(opportunityId) && opportunityId.startsWith('006')) { // Query Projects related to the provided Opportunity ID projects = [ SELECT Id, Name, MF_Loan_Amount__c, Date_to_Funded__c, Project_Number__c FROM Project__c WHERE Loan_Opportunity__c = :opportunityId ]; // Populate the wrapper responseWrapper.totalSize = projects.size(); responseWrapper.done = true; responseWrapper.records = projects; // Set the response body to JSON res.responseBody = Blob.valueOf(JSON.serialize(responseWrapper)); } else { // Query all Projects if no Opportunity ID is provided projects = [ SELECT Id, Name, MF_Loan_Amount__c, Date_to_Funded__c, Project_Number__c FROM Project__c Where Id = :opportunityId ]; res.responseBody = Blob.valueOf(JSON.serialize(projects)); } } catch (Exception ex) { res.statusCode = 500; res.responseBody = Blob.valueOf('Error retrieving projects: ' + ex.getMessage()); } } // Wrapper class for the response public class ProjectResponseWrapper { public Integer totalSize; public Boolean done; public List records; public ProjectResponseWrapper() { this.records = new List(); } } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/ProjectAPI.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 46 changes: 46 additions & 0 deletions46 force-app/main/default/classes/ProjectApiTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,46 @@ @isTest public class ProjectApiTest { @testSetup static void setupTestData() { Account testAccount = new Account(Name = 'Test Account'); insert testAccount; Opportunity opp1 = new Opportunity(Name = 'Test Opportunity 1', StageName = 'Prospecting', CloseDate = System.today().addDays(10), AccountId = testAccount.Id, Amount = 10000); Opportunity opp2 = new Opportunity(Name = 'Test Opportunity 2', StageName = 'Closed Won', CloseDate = System.today().addDays(5), AccountId = testAccount.Id, Amount = 20000); insert new List { opp1, opp2 }; Project__c proj = new Project__c(Name = '43546', MF_Loan_Amount__c = 3243, Date_to_Funded__c = System.today(), Loan_Opportunity__c = opp1.Id); insert proj; } @isTest static void testWithOpportunityId() { Opportunity opp = [SELECT Id FROM Opportunity WHERE Name = 'Test Opportunity 1' LIMIT 1]; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/opportunity/' + opp.Id; req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = new RestResponse(); Test.startTest(); ProjectAPI.getProjects(); Test.stopTest(); } @isTest static void testWithProjectId() { Project__c proj = [SELECT Id FROM Project__c WHERE Name = '43546' LIMIT 1]; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/opportunity/' + proj.Id; req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = new RestResponse(); Test.startTest(); ProjectAPI.getProjects(); Test.stopTest(); } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/ProjectApiTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 50 changes: 50 additions & 0 deletions50 force-app/main/default/classes/RequestItemAPI.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,50 @@ @RestResource(urlMapping='/requestItem/*') global without sharing class RequestItemAPI { @HttpGet global static void getrequestItem() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; String disburseReqId = req.requestURI.substring(req.requestURI.lastIndexOf('/') + 1); ReqItemResponseWrapper responseWrapper = new ReqItemResponseWrapper(); try { List reqItems; if (!String.isBlank(disburseReqId) && disburseReqId.startsWith('a08')) { reqItems = [ SELECT Id, Name FROM Requested_Item__c WHERE Disbursement_Request__c = :disburseReqId ]; responseWrapper.totalSize = reqItems.size(); responseWrapper.done = true; responseWrapper.records = reqItems; res.responseBody = Blob.valueOf(JSON.serialize(responseWrapper)); } else { reqItems = [ SELECT Id, Name FROM Requested_Item__c Where Id = :disburseReqId ]; res.responseBody = Blob.valueOf(JSON.serialize(reqItems)); } } catch (Exception ex) { res.statusCode = 500; res.responseBody = Blob.valueOf('Error retrieving projects: ' + ex.getMessage()); } } public class ReqItemResponseWrapper { public Integer totalSize; public Boolean done; public List records; public ReqItemResponseWrapper() { this.records = new List(); } } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/RequestItemAPI.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 52 changes: 52 additions & 0 deletions52 force-app/main/default/classes/RequestItemApiTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,52 @@ @isTest public class RequestItemApiTest { @testSetup static void setupTestData() { Account testAccount = new Account(Name = 'Test Account'); insert testAccount; Opportunity opp1 = new Opportunity(Name = 'Test Opportunity 1', StageName = 'Prospecting', CloseDate = System.today().addDays(10), AccountId = testAccount.Id, Amount = 10000); Opportunity opp2 = new Opportunity(Name = 'Test Opportunity 2', StageName = 'Closed Won', CloseDate = System.today().addDays(5), AccountId = testAccount.Id, Amount = 20000); insert new List { opp1, opp2 }; Project__c proj = new Project__c(Name = '43546', MF_Loan_Amount__c = 3243, Date_to_Funded__c = System.today(), Loan_Opportunity__c = opp1.Id); insert proj; Disbursement_Request__c dr = new Disbursement_Request__c(Disbursement__c = 344); insert dr; Requested_Item__c reqItem = new Requested_Item__c(name = 'test req', Disbursement_Request__c = dr.Id); insert reqItem; } @isTest static void testWithOpportunityId() { Disbursement_Request__c disReq = [SELECT Id FROM Disbursement_Request__c WHERE Disbursement__c = 344 LIMIT 1]; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/opportunity/' + disReq.Id; req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = new RestResponse(); Test.startTest(); RequestItemAPI.getrequestItem(); Test.stopTest(); } @isTest static void testWithProjectId() { Requested_Item__c reqItem = [SELECT Id FROM Requested_Item__c WHERE Name = 'test req' LIMIT 1]; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/opportunity/' + reqItem.Id; req.httpMethod = 'GET'; RestContext.request = req; RestContext.response = new RestResponse(); Test.startTest(); RequestItemAPI.getrequestItem(); Test.stopTest(); } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/RequestItemApiTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 21 changes: 19 additions & 2 deletions21 force-app/main/default/classes/ShowOppListClass.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -60,6 +60,19 @@ public without sharing class ShowOppListClass { FROM Opportunity FROM Opportunity WHERE AccountId = :accountId AND Status_Update_for_Client__c != 'Approved' WHERE AccountId = :accountId AND Status_Update_for_Client__c != 'Approved' ]; ]; // Get Projects associated with Opportunities Map projectCountMap = new Map(); List projectCounts = [ SELECT Loan_Opportunity__c, COUNT(Id) projectCount FROM Project__c WHERE Loan_Opportunity__c IN :opportunities GROUP BY Loan_Opportunity__c ]; for (AggregateResult ar : projectCounts) { projectCountMap.put((Id) ar.get('Loan_Opportunity__c'), (Integer) ar.get('projectCount')); } // Query FeedItems related to opportunities // Query FeedItems related to opportunities List feedItems = [ List feedItems = [ @@ -84,7 +97,8 @@ public without sharing class ShowOppListClass { // Create OpportunityWrapper list // Create OpportunityWrapper list for (Opportunity opp : opportunities) { for (Opportunity opp : opportunities) { Integer feedItemCount = feedItemCountMap.get(opp.Id) != null ? feedItemCountMap.get(opp.Id) : 0; Integer feedItemCount = feedItemCountMap.get(opp.Id) != null ? feedItemCountMap.get(opp.Id) : 0; opportunityWrappers.add(new OpportunityWrapper(opp, feedItemCount)); Integer projectCount = projectCountMap.containsKey(opp.Id) ? projectCountMap.get(opp.Id) : 0; opportunityWrappers.add(new OpportunityWrapper(opp, feedItemCount, projectCount)); } } for (Opportunity opp : pendingOpportunities) { for (Opportunity opp : pendingOpportunities) { //Integer feedItemCount = feedItemCountMap.get(opp.Id) != null ? feedItemCountMap.get(opp.Id) : 0; //Integer feedItemCount = feedItemCountMap.get(opp.Id) != null ? feedItemCountMap.get(opp.Id) : 0; @@ -101,10 +115,13 @@ public without sharing class ShowOppListClass { public Opportunity opportunity { get; set; } public Opportunity opportunity { get; set; } @AuraEnabled @AuraEnabled public Integer feedItemCount { get; set; } public Integer feedItemCount { get; set; } @AuraEnabled public Integer projectCount { get; set; } public OpportunityWrapper(Opportunity opp, Integer feedItemCount) { public OpportunityWrapper(Opportunity opp, Integer feedItemCount, Integer projectCount) { this.opportunity = opp; this.opportunity = opp; this.feedItemCount = feedItemCount; this.feedItemCount = feedItemCount; this.projectCount = projectCount; } } public OpportunityWrapper(Opportunity opp) { public OpportunityWrapper(Opportunity opp) { 206 changes: 206 additions & 0 deletions206 force-app/main/default/classes/SubmitApplicationService.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,206 @@ @RestResource(urlMapping='/SubmitApplicationForm/') global without sharing class SubmitApplicationService { @HttpPost global static ResponseWrapper updateAccountAndCreateOpportunity() { ResponseWrapper response = new ResponseWrapper(); try { RestRequest req = RestContext.request; String jsonInput = req.requestBody.toString(); SubmitApplicationWrapper application = (SubmitApplicationWrapper) JSON.deserialize(jsonInput, SubmitApplicationWrapper.class); //'005QL00000A7ZOWYA3 User currentUser = [SELECT Id,name, ContactId FROM User WHERE Id =:UserInfo.getUserId() LIMIT 1]; System.debug('currentUser '+currentUser); //:UserInfo.getUserId() String conId = currentUser.ContactId; if (currentUser.ContactId != null) { System.debug('currentUser.ContactId '+currentUser.ContactId); Contact currentContact = [SELECT Id, AccountId FROM Contact WHERE Id =: conId LIMIT 1]; System.debug('currentContact '+currentContact); if (currentContact != null && currentContact.AccountId != null) { Account existingAccount = [SELECT Id FROM Account WHERE Id = :currentContact.AccountId LIMIT 1]; System.debug('existingAccount '+existingAccount); if (existingAccount != null) { updateAccount(existingAccount, application); Opportunity newOpportunity = createOpportunity(existingAccount.Id, application); insert newOpportunity; updateContact(currentContact, application.OwnerInformation); Id contact1Id = currentContact.Id; Id contact2Id; if (application.OwnerInformation2 != null) { contact2Id = handleContact2(existingAccount.Id, application.OwnerInformation2); } sendEmailOfApplicationFormDetails(existingAccount.Id, contact1Id, contact2Id, newOpportunity.Id); response.status = 'success'; response.accountId = existingAccount.Id; response.contact1Id = contact1Id; response.contact2Id = contact2Id; response.opportunityId = newOpportunity.Id; } else { response.status = 'No account found associated with the current user.'; } } else { response.status = 'No contact found for the current user or contact is not associated with any account.'; } } else { response.status = 'Running user is not a community user or does not have a contact record.'; } } catch (Exception e) { System.debug('exception '+e.getMessage()); System.debug('e.getStackTraceString() '+e.getStackTraceString()); response.status = 'An error occurred: ' + e.getMessage(); response.stackTrace = e.getStackTraceString(); } return response; } private static void updateAccount(Account existingAccount, SubmitApplicationWrapper application) { existingAccount.BillingCity = application.BusinessInformation.BusinessAddress.CITY; existingAccount.BillingPostalCode = application.BusinessInformation.BusinessAddress.ZIP_CODE; existingAccount.BillingState = application.BusinessInformation.BusinessAddress.STATE; existingAccount.BillingStreet = application.BusinessInformation.BusinessAddress.STREET_ADDRESS; existingAccount.Description = application.BusinessInformation.Type_of_Work; existingAccount.EIN__c = application.BusinessInformation.Federal_Tax_ID_Number; //existingAccount.Email__c = application.OwnerInformation.Email; if(application.BusinessInformation.Number_of_Employees != null) { existingAccount.NumberOfEmployees = Integer.valueOf(application.BusinessInformation.Number_of_Employees); } existingAccount.Phone = application.BusinessInformation.businessPhone; existingAccount.Website = application.BusinessInformation.Website; existingAccount.Year_Founded__c = application.BusinessInformation.Year_Business_Was_Founded; if(application.BusinessInformation.Number_of_Owners_Above_10 != null) { existingAccount.of_Owners__c = Integer.valueOf(application.BusinessInformation.Number_of_Owners_Above_10); } update existingAccount; } public static Opportunity createOpportunity(Id accountId, SubmitApplicationWrapper application) { Opportunity newOpportunity = new Opportunity(); newOpportunity.AccountId = accountId; newOpportunity.App_Signature__c = application.VerifyAndSubmit.Signature; newOpportunity.Name = application.BusinessInformation.Business_Name; newOpportunity.Loan_Amount_Requested__c = application.BusinessInformation.Loan_Amount_Requested; newOpportunity.StageName = 'Application'; newOpportunity.CloseDate = Date.today().addDays(30); newOpportunity.Bad_Debt__c = application.AdditionalInformation.Are_you_delinquent_or_in_default_of_any_debt_or_other_loans_including_Federal_or; newOpportunity.Bankruptcy__c = application.AdditionalInformation.Have_you_or_any_of_the_majority_owners_ever_filed_for_bankruptcy; newOpportunity.Confirmation_Email__c = application.VerifyAndSubmit.Email_for_Confirmation; newOpportunity.Current_Lawsuits__c = application.AdditionalInformation.Are_you_or_any_of_the_majority_owners_party_to_any_current_lawsuits; //newOpportunity.Overhead_Debt_Schedule__c = application.DebtSchedule.OverheadAndDebtSchedule; newOpportunity.Status_Update_for_Client__c = 'Application Review'; newOpportunity.UCC_Filings__c = application.AdditionalInformation.Are_there_any_UCC_Filings_against_the_company_or_any_of_its_majority_owners; newOpportunity.of_active_contracts_POs__c = application.BusinessInformation.purchaseOrder; newOpportunity.Signed_App__c = application.VerifyAndSubmit.Date1; return newOpportunity; } public static void updateContact(Contact currentContact, SubmitApplicationWrapper.OwnerInformation ownerInfo) { currentContact.FirstName = ownerInfo.Name.First; currentContact.LastName = ownerInfo.Name.Last; currentContact.Email = ownerInfo.Email; currentContact.Phone = ownerInfo.cellPhone; //currentContact.MailingStreet = ownerInfo.homeAddress; currentContact.MailingStreet = ownerInfo.HomeAddress.street; currentContact.MailingState = ownerInfo.HomeAddress.state; currentContact.MailingPostalCode = ownerInfo.HomeAddress.postalCode; currentContact.MailingCountry = ownerInfo.HomeAddress.country; currentContact.MailingCity = ownerInfo.HomeAddress.city; currentContact.Title = ownerInfo.Title; currentContact.Date_of_Birth__c = Date.valueOf(ownerInfo.Date_Of_Birth); currentContact.SSN__c = ownerInfo.Social_Security_Number != null ? ownerInfo.Social_Security_Number.replaceAll('-', '') : null; //currentContact.SSN__c = ownerInfo.Social_Security_Number; currentContact.Married__c = ownerInfo.Married; currentContact.Ownership__c = Decimal.valueOf(ownerInfo.Percent_Ownership); currentContact.Do_you_have_a_life_insurance_policy__c = ownerInfo.Do_you_have_a_life_insurance_policy; currentContact.Life_Insurance_Policy_Limit__c = ownerInfo.If_yes_what_is_the_policy_limit; currentContact.Web_Entry__c = True; update currentContact; } public static Id handleContact2(Id accountId, SubmitApplicationWrapper.OwnerInformation2 ownerInfo2) { List contact2 = [SELECT Id FROM Contact WHERE Email =:ownerInfo2.Email2 AND AccountId =:accountId LIMIT 1]; Contact conn2; if (!contact2.isEmpty() ) { conn2 = contact2[0]; conn2 = updateContact2(conn2, ownerInfo2); update conn2; return conn2.Id; } else { Contact newContact2 = new Contact(); newContact2 = updateContact2(newContact2, ownerInfo2); newContact2.AccountId = accountId; newContact2.MobilePhone = ownerInfo2.cellPhone2; newContact2.Email = ownerInfo2.Email2; insert newContact2; return newContact2.Id; } } public static Contact updateContact2(Contact contact, SubmitApplicationWrapper.OwnerInformation2 ownerInfo2) { contact.FirstName = ownerInfo2.Name.First2; contact.LastName = ownerInfo2.Name.Last2; //contact.Email = ownerInfo2.Email2; //contact.MobilePhone = ownerInfo2.cellPhone2; //contact.MailingStreet = ownerInfo2.homeAddress2; contact.MailingStreet = ownerInfo2.HomeAddress2.street2; contact.MailingState = ownerInfo2.HomeAddress2.state2; contact.MailingPostalCode = ownerInfo2.HomeAddress2.postalCode2; contact.MailingCountry = ownerInfo2.HomeAddress2.country2; contact.MailingCity = ownerInfo2.HomeAddress2.city2; contact.Title = ownerInfo2.Title2; contact.Date_of_Birth__c = Date.valueOf(ownerInfo2.Date_Of_Birth2); contact.SSN__c = ownerInfo2.Social_Security_Number2 != null ? ownerInfo2.Social_Security_Number2.replaceAll('-', '') : null; //contact.SSN__c = ownerInfo2.Social_Security_Number2; contact.Married__c = ownerInfo2.Married2; contact.Ownership__c = Decimal.valueOf(ownerInfo2.Percent_Ownership2); contact.Do_you_have_a_life_insurance_policy__c = ownerInfo2.Do_you_have_a_life_insurance_policy2; contact.Life_Insurance_Policy_Limit__c = ownerInfo2.If_yes_what_is_the_policy_limit2; contact.Web_Entry__c = True; return contact; } public static void sendEmailOfApplicationFormDetails(String accId, String conId1, String conId2, String oppId){ sendEmailOfApplicationFormDetails.inputVariables inputVar = new sendEmailOfApplicationFormDetails.inputVariables(); inputVar.accountId = accId; inputVar.contactOwnerId = conId1; inputVar.contactOwnerId2 = conId2; inputVar.oppId = oppId; List inputList = new List(); inputList.add(inputVar); List outputList = sendEmailOfApplicationFormDetails.sendEmailOfApplicationDetailForm(inputList); for (sendEmailOfApplicationFormDetails.outputVariables outputVar : outputList) { System.debug('success: ' + outputVar.success); System.debug('message: ' + outputVar.message); } } global class ResponseWrapper { public String status { get; set; } public Id accountId { get; set; } public Id contact1Id { get; set; } public Id contact2Id { get; set; } public Id opportunityId { get; set; } public String stackTrace { get; set; } } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitApplicationService.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 73 changes: 73 additions & 0 deletions73 force-app/main/default/classes/SubmitApplicationServiceTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,73 @@ @isTest public class SubmitApplicationServiceTest { @testSetup static void testSetup(){ Account acc = new Account(name = 'kg parry'); insert acc; Contact testContact = new Contact(FirstName = 'John', LastName = 'Doe', Email = 'john.doe@example.com', AccountId = acc.Id); insert testContact; User testUser = new User( Username = 'tstusr@example.com', Email = 'testuser@example.com', LastName = 'User', Alias = 'testuser', TimeZoneSidKey = 'America/New_York', LocaleSidKey = 'en_US', EmailEncodingKey = 'UTF-8', ProfileId = [SELECT Id FROM Profile WHERE Name = 'Customer Community Login User' LIMIT 1].Id, LanguageLocaleKey = 'en_US', ContactId = testContact.Id ); insert testUser; } @isTest static void testUpdateAccountAndCreateOpportunity_Success() { User testUser = [SELECT Id, name, ContactId, Profile.Name FROM User Where Email = 'testuser@example.com' Limit 1]; String jsonInput = '{ "BusinessInformation": { "BusinessAddress": { "CITY": "New York", "ZIP_CODE": "10001", "STATE": "NY", "STREET_ADDRESS": "123 Main St" }, "Type_of_Work": "Construction", "Federal_Tax_ID_Number": "123456789", "Number_of_Employees": "50", "businessPhone": "123-456-7890", "Website": "www.example.com", "Year_Business_Was_Founded": "2000", "Number_of_Owners_Above_10": "2", "Loan_Amount_Requested": "50000", "Business_Name": "Test Business" }, "VerifyAndSubmit": { "Signature": "John Doe", "Email_for_Confirmation": "john.doe@example.com", "Date1": "2023-01-01" }, "AdditionalInformation": { "Are_you_delinquent_or_in_default_of_any_debt_or_other_loans_including_Federal_or": "No", "Have_you_or_any_of_the_majority_owners_ever_filed_for_bankruptcy": "No", "Are_you_or_any_of_the_majority_owners_party_to_any_current_lawsuits": "No", "Are_there_any_UCC_Filings_against_the_company_or_any_of_its_majority_owners": "No" }, "OwnerInformation": { "Name": { "First": "John", "Last": "Doe" }, "Email": "john.doe@example.com", "cellPhone": "123-456-7890", "HomeAddress": { "street": "123 Main St", "state": "NY", "postalCode": "10001", "country": "USA", "city": "New York" }, "Title": "Owner", "Date_Of_Birth": "1980-01-01", "Social_Security_Number": "123-45-6789", "Married": "Yes", "Percent_Ownership": "100", "Do_you_have_a_life_insurance_policy": "Yes", "If_yes_what_is_the_policy_limit": "500000" }, "OwnerInformation2": { "Name": { "First2": "John", "Last2": "Doe" }, "Email2": "john.doe@example.com", "cellPhone2": "123-456-7890", "HomeAddress2": { "street2": "123 Main St", "state2": "NY", "postalCode2": "10001", "country2": "USA", "city2": "New York" }, "Title2": "Owner", "Date_Of_Birth2": "1980-01-01", "Social_Security_Number2": "123-45-6789", "Married2": "Yes", "Percent_Ownership2": "100", "Do_you_have_a_life_insurance_policy2": "Yes", "If_yes_what_is_the_policy_limit2": "500000" } } }'; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/SubmitApplicationForm/'; RestResponse res = new RestResponse(); req.requestBody = Blob.valueOf(jsonInput); req.httpMethod = 'POST'; RestContext.request = req; //RestContext.response = res; Test.startTest(); PermissionSet mfPermissionSet = [SELECT Id FROM PermissionSet WHERE Name = 'Mobilization_Funding_Experience_Member' LIMIT 1]; PermissionSetAssignment psa = new PermissionSetAssignment( AssigneeId = testUser.Id, PermissionSetId = mfPermissionSet.Id ); insert psa; System.runAs(testUser){ SubmitApplicationService.ResponseWrapper response = SubmitApplicationService.updateAccountAndCreateOpportunity(); } Test.stopTest(); // Verify the response /*System.assertEquals('success', response.status, 'The status should be success.'); System.assertNotEquals(null, response.accountId, 'Account ID should not be null.'); System.assertNotEquals(null, response.contact1Id, 'Contact1 ID should not be null.'); System.assertNotEquals(null, response.opportunityId, 'Opportunity ID should not be null.');*/ } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitApplicationServiceTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 108 changes: 108 additions & 0 deletions108 force-app/main/default/classes/SubmitApplicationWrapper.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,108 @@ public class SubmitApplicationWrapper { public BusinessInformation BusinessInformation; public AdditionalInformation AdditionalInformation; public OwnerInformation OwnerInformation; public OwnerInformation2 OwnerInformation2; public DebtSchedule DebtSchedule; public UploadingYourDocuments UploadingYourDocuments; public VerifyAndSubmit VerifyAndSubmit; public class BusinessInformation { public String Business_Name; public BusinessAddress BusinessAddress; public String Website; public String Year_Business_Was_Founded; public String Type_of_Work; public String businessPhone; public String Number_of_Employees; public Decimal Federal_Tax_ID_Number; public Decimal Loan_Amount_Requested; public String purchaseOrder; public String Number_of_Owners_Above_10; } public class BusinessAddress { public String STREET_ADDRESS; public String CITY; public String STATE; public String ZIP_CODE; } public class AdditionalInformation { public String Are_there_any_UCC_Filings_against_the_company_or_any_of_its_majority_owners; public String Are_you_delinquent_or_in_default_of_any_debt_or_other_loans_including_Federal_or; public String Have_you_or_any_of_the_majority_owners_ever_filed_for_bankruptcy; public String Are_you_or_any_of_the_majority_owners_party_to_any_current_lawsuits; } public class OwnerInformation { public Name Name; //public String homeAddress; public HomeAddress HomeAddress; public String cellPhone; public String Email; public String Social_Security_Number; public String Married; public String Date_Of_Birth; public String Title; public String Percent_Ownership; public String Do_you_have_a_life_insurance_policy; public String If_yes_what_is_the_policy_limit; } public class HomeAddress { public String street; public String city; public String state; public String postalCode; public String country; } public class Name { public String First; public String Last; } public class OwnerInformation2 { public Name2 Name; //public String homeAddress2; public HomeAddress2 HomeAddress2; public String cellPhone2; public String Email2; public String Social_Security_Number2; public String Married2; public String Date_Of_Birth2; public String Title2; public String Percent_Ownership2; public String Do_you_have_a_life_insurance_policy2; public String If_yes_what_is_the_policy_limit2; } public class HomeAddress2 { public String street2; public String city2; public String state2; public String postalCode2; public String country2; } public class Name2 { public String First2; public String Last2; } public class DebtSchedule { public String OverheadAndDebtSchedule; } public class UploadingYourDocuments { public String uploadDocuments; } public class VerifyAndSubmit { public Date Date1; public String Email_for_Confirmation; public String Signature; } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitApplicationWrapper.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 117 changes: 117 additions & 0 deletions117 force-app/main/default/classes/SubmitDisbursementRequestService.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,117 @@ @RestResource(urlMapping='/SubmitDisbursementRequest/') global without sharing class SubmitDisbursementRequestService { @HttpPost global static ResponseWrapper handleDisbursementRequest() { ResponseWrapper response = new ResponseWrapper(); try { RestRequest req = RestContext.request; String jsonInput = req.requestBody.toString(); DisbursementRequestWrapper requestWrapper = (DisbursementRequestWrapper) JSON.deserialize(jsonInput, DisbursementRequestWrapper.class); Disbursement_Request__c disReq = processDisbursementRequest(requestWrapper); insert disReq; List requestedItems = processRequestedItems(requestWrapper.itemDescriptions, disReq.Id); response.requestedItemIds = new List(); List reqItemList = new List(); for (Requested_Item__c item : requestedItems){ response.requestedItemIds.add(item.Id); reqItemList.add(item); } sendEmailOfDisbursementRequestFormDetails(disReq.Id, reqItemList); response.status = 'success'; response.message = 'Disbursement request processed successfully.'; response.disbursementRequestId = disReq.Id; } catch (Exception e) { response.status = 'error'; response.status = 'An error occurred: ' + e.getMessage(); response.stackTrace = e.getStackTraceString(); } return response; } public static Disbursement_Request__c processDisbursementRequest(DisbursementRequestWrapper request) { Disbursement_Request__c dr = new Disbursement_Request__c(); dr.Account_Name__c = request.DisbursementRequest.Account_Name; dr.Bank_Account_Number__c = request.DisbursementRequest.Bank_Account_Number; dr.Bank_Name__c = request.DisbursementRequest.Bank_Name; dr.Bank_Routing_Number__c = request.DisbursementRequest.Bank_Routing_Number; dr.City__c = request.DisbursementRequest.PayeeAddress.payeeAddress1; dr.Comments__c = request.VerifyAndSubmit.additionalCommentsSpecialInstructions; dr.Disbursement_Type__c = request.DisbursementRequest.expenseType; dr.Disbursement__c = request.DisbursementRequest.Disbursement_Number; dr.Issue_Check_To__c = request.DisbursementRequest.Mail_Check_To; dr.Loan_Number__c = request.DisbursementRequest.loanNumberLookup; dr.Payee_Contact_Email__c = request.DisbursementRequest.payeeContactEmail; dr.Payee_Contact_Name__c = request.DisbursementRequest.PayeeContactName.firstName + request.DisbursementRequest.PayeeContactName.lastName; dr.Payee_Name__c = request.DisbursementRequest.payeeName; dr.Payment_Method__c = request.DisbursementRequest.paymentMethod; dr.Phone__c = request.DisbursementRequest.payeePhone; dr.Project_Lookup__c = request.DisbursementRequest.projectLookup; dr.Requester_Email__c = request.VerifyAndSubmit.requesterEmail; dr.General_Contractor_Contract_Owner__c = request.VerifyAndSubmit.PROJECTOWNER_Lookup; dr.Requester_Name__c = request.VerifyAndSubmit.signature; //dr.State__c = request.State__c; dr.Status__c = 'New'; //dr.Street_Address__c = request.Street_Address__c; //dr.Zip_Code__c = request.Zip_Code__c; //dr.Signature__c = request.Signature__c; return dr; } public static List processRequestedItems(List items, Id disbursementRequestId) { List requestedItems = new List(); for (DisbursementRequestWrapper.ItemDescription item : items) { Requested_Item__c requestedItem = new Requested_Item__c(); requestedItem.Name = item.Item; requestedItem.Description_Work__c = item.Description_Work; requestedItem.Invoice_Date__c = Date.valueOf(item.invoiceDate); requestedItem.Invoice_Amount__c = Decimal.valueOf(item.invoiceAmount.replace('$', '').replace(',', '')); requestedItem.Invoice__c = item.invoice; requestedItem.Invoice_Due_Date__c = Date.valueOf(item.invoiceDueDate); requestedItem.Disbursement_Request__c = disbursementRequestId; requestedItems.add(requestedItem); } if (!requestedItems.isEmpty()) { insert requestedItems; } return requestedItems; } public static void sendEmailOfDisbursementRequestFormDetails(Id disReqId, List ReqItemId){ sendEmailOfDisbursementReqForm.inputVariables inputVar = new sendEmailOfDisbursementReqForm.inputVariables(); inputVar.disbursementReqId = disReqId; inputVar.requestedItemIds = ReqItemId; List inputList = new List(); inputList.add(inputVar); List outputList = sendEmailOfDisbursementReqForm.sendEmailOfDisbursementRequestForm(inputList); for (sendEmailOfDisbursementReqForm.outputVariables outputVar : outputList) { System.debug('success: ' + outputVar.result); //System.debug('message: ' + outputVar.message); } } global class ResponseWrapper { public String status; public String message; public String stackTrace; public Id disbursementRequestId; public List requestedItemIds; } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitDisbursementRequestService.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 62 changes: 62 additions & 0 deletions62 force-app/main/default/classes/SubmitDisbursementRequestServiceTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,62 @@ @isTest public class SubmitDisbursementRequestServiceTest { @testSetup static void testSetup(){ Account acc = new Account(name = 'kg parry'); insert acc; Contact testContact = new Contact(FirstName = 'John', LastName = 'Doe', Email = 'john.doe@example.com', AccountId = acc.Id); insert testContact; Opportunity opp = new Opportunity(name = 'test opp', StageName = 'Prospecting', CloseDate = System.today(), AccountId = acc.Id); insert opp; Project__c proj = new Project__c(Name = 'test proj', Account_Name__c = acc.Id); insert proj; User testUser = new User( Username = 'tstusr@example.com', Email = 'testuser@example.com', LastName = 'User', Alias = 'testuser', TimeZoneSidKey = 'America/New_York', LocaleSidKey = 'en_US', EmailEncodingKey = 'UTF-8', ProfileId = [SELECT Id FROM Profile WHERE Name = 'Customer Community Login User' LIMIT 1].Id, LanguageLocaleKey = 'en_US', ContactId = testContact.Id ); insert testUser; } @isTest static void testUpdateAccountAndCreateOpportunity_Success() { User testUser = [SELECT Id, name, ContactId, Profile.Name FROM User Where Email = 'testuser@example.com' Limit 1]; Project__c proj = [Select id from Project__c where name = 'test proj' Limit 1]; String jsonInput = '{"disbursementRequest": {"loanNumberLookup": "LN123456","expenseType": "Material", "projectLookup": "'+proj.Id+'", "payeeContactName": { "firstName": "John", "lastName": "Doe"}, "payeeContactEmail": "john.doe@example.com", "Disbursement_Number": 123, "paymentMethod": "Wire", "payeeAddress": { "payeeAddress1": "123 Main St, Suite 100"}, "payeeName": "John Doe", "payeePhone": "5551234567", "Mail_Check_To": "John Doe", "Account_Name": "Doe Enterprises", "Bank_Routing_Number": "987654321", "Bank_Account_Number": "123456789", "Bank_Name": "Bank of Example" }, "itemDescriptions": [{ "Item": "Item 1", "Description_Work": "Description of Item 1", "invoiceDate": "2024-09-01", "invoiceAmount": "$1000.00", "invoice": "INV001", "invoiceDueDate": "2024-09-15"}, { "Item": "Item 2", "Description_Work": "Description of Item 2", "invoiceDate": "2024-09-05", "invoiceAmount": "$2000.00", "invoice": "INV002", "invoiceDueDate": "2024-09-20" } ], "verifyAndSubmit": { "Name": "Disbursement Request Verification", "ClientLookup": "CL123456", "ClientLookup2": "CL789012", "PROJECTOWNER_Lookup": "PO123456", "ProjNameLookup": "Project XYZ", "submitDate": "2024-09-10", "signature": "John Doe", "requesterEmail": "john.doe@example.com", "additionalCommentsSpecialInstructions": "Please process urgently." }}'; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/SubmitApplicationForm/'; RestResponse res = new RestResponse(); req.requestBody = Blob.valueOf(jsonInput); req.httpMethod = 'POST'; RestContext.request = req; Test.startTest(); PermissionSet mfPermissionSet = [SELECT Id FROM PermissionSet WHERE Name = 'Mobilization_Funding_Experience_Member' LIMIT 1]; PermissionSetAssignment psa = new PermissionSetAssignment( AssigneeId = testUser.Id, PermissionSetId = mfPermissionSet.Id ); insert psa; System.runAs(testUser){ SubmitDisbursementRequestService.ResponseWrapper response = SubmitDisbursementRequestService.handleDisbursementRequest(); } Test.stopTest(); } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitDisbursementRequestServiceTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 91 changes: 91 additions & 0 deletions91 force-app/main/default/classes/SubmitNewLoanApplicationService.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,91 @@ @RestResource(urlMapping='/SubmitNewLoanApplicationForm/') global without sharing class SubmitNewLoanApplicationService { @HttpPost global static ResponseWrapper processNewApplication() { ResponseWrapper response = new ResponseWrapper(); try { RestRequest req = RestContext.request; String jsonInput = req.requestBody.toString(); SubmitNewLoanRequestWrapper application = (SubmitNewLoanRequestWrapper) JSON.deserialize(jsonInput, SubmitNewLoanRequestWrapper.class); User currentUser = [SELECT Id, ContactId FROM User WHERE Id =: UserInfo.getUserId() LIMIT 1]; if (currentUser.ContactId != null) { Contact currentContact = [SELECT Id, AccountId FROM Contact WHERE Id = :currentUser.ContactId LIMIT 1]; if (currentContact != null && currentContact.AccountId != null) { Account existingAccount = [SELECT Id FROM Account WHERE Id = :currentContact.AccountId LIMIT 1]; if (existingAccount != null) { //updateAccount(existingAccount, application); Opportunity newOpportunity = createOpportunity(existingAccount.Id, application); insert newOpportunity; sendEmailOfNewProjectFormDetails(currentContact.Id, newOpportunity.Id); response.status = 'success'; response.accountId = existingAccount.Id; response.opportunityId = newOpportunity.Id; } else { response.status = 'No account found associated with the current user.'; } } else { response.status = 'No contact found for the current user or contact is not associated with any account.'; } } else { response.status = 'Running user is not a community user or does not have a contact record.'; } } catch (Exception e) { response.status = 'An error occurred: ' + e.getMessage(); response.stackTrace = e.getStackTraceString(); } return response; } /*public static void updateAccount(Account existingAccount, SubmitNewLoanRequestWrapper application) { existingAccount.Name = application.BusinessInformation.Business_Name; existingAccount.Description = application.BusinessInformation.Project_Name; update existingAccount; }*/ public static Opportunity createOpportunity(Id accountId, SubmitNewLoanRequestWrapper application) { Opportunity newOpportunity = new Opportunity(); newOpportunity.AccountId = accountId; newOpportunity.App_Signature__c = application.VerifyAndSubmit.Signature; newOpportunity.Name = application.BusinessInformation.Project_Name; newOpportunity.StageName = 'Application'; newOpportunity.Signed_App__c = application.VerifyAndSubmit.Date1; newOpportunity.CloseDate = Date.today().addDays(60); newOpportunity.UCC_Filings__c = application.AdditionalInformation.Are_there_any_new_UCC_Filings_against_the_company_or_any_of_its_majority_owners; newOpportunity.Bad_Debt__c = application.AdditionalInformation.Are_you_delinquent_or_in_default_of_any_debt_or_other_loans_including_Federal_or; newOpportunity.Bankruptcy__c = application.AdditionalInformation.Are_there_any_new_bankruptcy_fillings_by_you_or_your_majority_owners; newOpportunity.Current_Lawsuits__c = application.AdditionalInformation.Are_you_or_any_of_the_majority_owners_party_to_any_current_lawsuits_not_previous; newOpportunity.Confirmation_Email__c = application.VerifyAndSubmit.Email_for_Confirmation; newOpportunity.Status_Update_for_Client__c = 'Application Review'; return newOpportunity; } public static void sendEmailOfNewProjectFormDetails(String conId1, String oppId){ sendEmailOfNewProjectFormDetails.inputVariables inputVar = new sendEmailOfNewProjectFormDetails.inputVariables(); inputVar.contactId = conId1; inputVar.oppId = oppId; List inputList = new List(); inputList.add(inputVar); List outputList = sendEmailOfNewProjectFormDetails.sendEmailOfNewProjectsForm(inputList); for (sendEmailOfNewProjectFormDetails.outputVariables outputVar : outputList) { System.debug('success: ' + outputVar.result); //System.debug('message: ' + outputVar.message); } } global class ResponseWrapper { public String status { get; set; } public Id accountId { get; set; } public Id opportunityId { get; set; } public String stackTrace { get; set; } } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitNewLoanApplicationService.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 69 changes: 69 additions & 0 deletions69 force-app/main/default/classes/SubmitNewLoanApplicationServiceTest.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,69 @@ @isTest public class SubmitNewLoanApplicationServiceTest { @testSetup static void testSetup(){ Account acc = new Account(name = 'kg parry'); insert acc; Contact testContact = new Contact(FirstName = 'John', LastName = 'Doe', Email = 'john.doe@example.com', AccountId = acc.Id); insert testContact; User testUser = new User( Username = 'tstusr@example.com', Email = 'testuser@example.com', LastName = 'User', Alias = 'testuser', TimeZoneSidKey = 'America/New_York', LocaleSidKey = 'en_US', EmailEncodingKey = 'UTF-8', ProfileId = [SELECT Id FROM Profile WHERE Name = 'Customer Community Login User' LIMIT 1].Id, LanguageLocaleKey = 'en_US', ContactId = testContact.Id ); insert testUser; } @isTest static void testUpdateAccountAndCreateOpportunity_Success() { User testUser = [SELECT Id, name, ContactId, Profile.Name FROM User Where Email = 'testuser@example.com' Limit 1]; String jsonInput = '{ "BusinessInformation": { "Business_Name": "Example Business LLC", "Project_Name": "test proj"}, "AdditionalInformation": {"Are_there_any_new_UCC_Filings_against_the_company_or_any_of_its_majority_owners": "yes", "Are_you_delinquent_or_in_default_of_any_debt_or_other_loans_including_Federal_or": "No", "Are_there_any_new_bankruptcy_fillings_by_you_or_your_majority_owners": "Yes", "Are_you_or_any_of_the_majority_owners_party_to_any_current_lawsuits_not_previous": "Yes"}, "VerifyAndSubmit": { "Date": "2024-09-11", "Email_for_Confirmation": "testefc@gmail.com", "Signature": "test sgn" }}'; RestRequest req = new RestRequest(); req.requestURI = '/services/apexrest/SubmitApplicationForm/'; RestResponse res = new RestResponse(); req.requestBody = Blob.valueOf(jsonInput); req.httpMethod = 'POST'; RestContext.request = req; //RestContext.response = res; Test.startTest(); PermissionSet mfPermissionSet = [SELECT Id FROM PermissionSet WHERE Name = 'Mobilization_Funding_Experience_Member' LIMIT 1]; PermissionSetAssignment psa = new PermissionSetAssignment( AssigneeId = testUser.Id, PermissionSetId = mfPermissionSet.Id ); insert psa; System.runAs(testUser){ SubmitNewLoanApplicationService.ResponseWrapper response = SubmitNewLoanApplicationService.processNewApplication(); } Test.stopTest(); // Verify the response /*System.assertEquals('success', response.status, 'The status should be success.'); System.assertNotEquals(null, response.accountId, 'Account ID should not be null.'); System.assertNotEquals(null, response.contact1Id, 'Contact1 ID should not be null.'); System.assertNotEquals(null, response.opportunityId, 'Opportunity ID should not be null.');*/ } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitNewLoanApplicationServiceTest.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 28 changes: 28 additions & 0 deletions28 force-app/main/default/classes/SubmitNewLoanRequestWrapper.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,28 @@ public class SubmitNewLoanRequestWrapper { public BusinessInformation BusinessInformation; public AdditionalInformation AdditionalInformation; public UploadingYourDocuments UploadingYourDocuments; public VerifyAndSubmit VerifyAndSubmit; public class BusinessInformation { public String Business_Name; public String Project_Name; } public class AdditionalInformation { public String Are_there_any_new_UCC_Filings_against_the_company_or_any_of_its_majority_owners; public String Are_you_delinquent_or_in_default_of_any_debt_or_other_loans_including_Federal_or; public String Are_there_any_new_bankruptcy_fillings_by_you_or_your_majority_owners; public String Are_you_or_any_of_the_majority_owners_party_to_any_current_lawsuits_not_previous; } public class UploadingYourDocuments { public String UploadDocuments; } public class VerifyAndSubmit { public Date Date1; public String Email_for_Confirmation; public String Signature; } } 5 changes: 5 additions & 0 deletions5 force-app/main/default/classes/SubmitNewLoanRequestWrapper.cls-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -0,0 +1,5 @@ 61.0 Active 18 changes: 10 additions & 8 deletions18 force-app/main/default/classes/sendEmailOfApplicationFormDetails.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -19,7 +19,7 @@ public class sendEmailOfApplicationFormDetails { outputVariables outputVar = new outputVariables(); outputVariables outputVar = new outputVariables(); try { //try { if (inputVariable.accountId != null) { if (inputVariable.accountId != null) { acc = [SELECT Id, Name, of_Owners__c, Year_Founded__c, Website, Phone, NumberOfEmployees, Email__c, EIN__c, Description, BillingStreet, BillingState, BillingPostalCode, BillingCity acc = [SELECT Id, Name, of_Owners__c, Year_Founded__c, Website, Phone, NumberOfEmployees, Email__c, EIN__c, Description, BillingStreet, BillingState, BillingPostalCode, BillingCity FROM Account WHERE Id = :inputVariable.accountId LIMIT 1]; FROM Account WHERE Id = :inputVariable.accountId LIMIT 1]; @@ -373,29 +373,31 @@ public class sendEmailOfApplicationFormDetails { outputVar.success = true; outputVar.success = true; outputVar.message = 'Email sent successfully.'; outputVar.message = 'Email sent successfully.'; outputVariablesList.add(outputVar); outputVariablesList.add(outputVar); } catch (Exception ex) { /*} catch (Exception ex) { System.debug('Exception '+ex); System.debug('Exception '+ex); outputVar.success = false; outputVar.success = false; outputVar.message = ex.getMessage(); outputVar.message = ex.getMessage(); outputVariablesList.add(outputVar); outputVariablesList.add(outputVar); throw new AuraHandledException(ex.getMessage()); throw new AuraHandledException(ex.getMessage() + ' ' +ex.getStackTraceString()); } }*/ } } return outputVariablesList; return outputVariablesList; } } public static void createAndLinkPdfDocument(String emailBody, Id linkedEntityId) { public static void createAndLinkPdfDocument(String emailBody, Id linkedEntityId) { Blob pdfBlob = Blob.toPdf(emailBody); FormUtility.createAndLinkPdfDocument(emailBody, linkedEntityId, 'Application Form Details', 'ApplicationFormDetails.pdf'); /* ContentVersion contentVersion = new ContentVersion( ContentVersion contentVersion = new ContentVersion( Title = 'Application Form Details', Title = 'Application Form Details', PathOnClient = 'ApplicationFormDetails.pdf', PathOnClient = 'ApplicationFormDetails.pdf', VersionData = pdfBlob, VersionData = pdfBlob, IsMajorVersion = true, IsMajorVersion = true, ContentLocation = 'S' ContentLocation = 'S' ); ); insert contentVersion; insert as system contentVersion; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; @@ -404,7 +406,7 @@ public class sendEmailOfApplicationFormDetails { LinkedEntityId = linkedEntityId, LinkedEntityId = linkedEntityId, Visibility = 'AllUsers' Visibility = 'AllUsers' ); ); insert contentDocLink; insert as system contentDocLink; */ } } public class inputVariables { public class inputVariables { 8 changes: 8 additions & 0 deletions8 force-app/main/default/classes/sendEmailOfDisbursementReqForm.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -326,6 +326,14 @@ public class sendEmailOfDisbursementReqForm { IsMajorVersion = true, IsMajorVersion = true, ContentLocation = 'S' ContentLocation = 'S' ); ); if (Test.isRunningTest()) { try { Id netId = [SELECT Id FROM Network LIMIT 1].Id; contentVersion.NetworkId = netId; } catch (Exception e) { System.debug('Not in a network context: ' + e.getMessage()); } } insert contentVersion; insert contentVersion; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; 13 changes: 11 additions & 2 deletions13 force-app/main/default/classes/sendEmailOfNewProjectFormDetails.cls Viewed Original file line number Original file line Diff line number Diff line change @@ -162,7 +162,8 @@ public class sendEmailOfNewProjectFormDetails { } } public static void createAndLinkPdfDocument(String emailBody, Id linkedEntityId) { public static void createAndLinkPdfDocument(String emailBody, Id linkedEntityId) { Blob pdfBlob = Blob.toPdf(emailBody); FormUtility.createAndLinkPdfDocument(emailBody, linkedEntityId, 'New Loan Request as Existing Form Details', 'NewLoanRequestAsExistingFormDetails.pdf'); /*Blob pdfBlob = Blob.toPdf(emailBody); ContentVersion contentVersion = new ContentVersion( ContentVersion contentVersion = new ContentVersion( Title = 'New Project Form Details', Title = 'New Project Form Details', @@ -171,6 +172,14 @@ public class sendEmailOfNewProjectFormDetails { IsMajorVersion = true, IsMajorVersion = true, ContentLocation = 'S' ContentLocation = 'S' ); ); if (Test.isRunningTest()) { try { Id netId = [SELECT Id FROM Network LIMIT 1].Id; contentVersion.NetworkId = netId; } catch (Exception e) { System.debug('Not in a network context: ' + e.getMessage()); } } insert contentVersion; insert contentVersion; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; contentVersion = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion.Id]; @@ -180,7 +189,7 @@ public class sendEmailOfNewProjectFormDetails { LinkedEntityId = linkedEntityId, LinkedEntityId = linkedEntityId, Visibility = 'AllUsers' Visibility = 'AllUsers' ); ); insert contentDocLink; insert contentDocLink;*/ } } public class inputVariables { public class inputVariables { 12 changes: 6 additions & 6 deletions12 force-app/main/default/flows/Submit_Application_Form.flow-meta.xml Viewed Original file line number Original file line Diff line number Diff line change @@ -752,7 +752,7 @@ LEN( {!Year_Business_Was_Founded}) < 5 LEN( {!Year_Business_Was_Founded}) < 5 Application {!$Flow.CurrentDateTime} Application {!$Flow.CurrentDateTime} Copy_1_of_Iterate_File_Upload Copy_1_of_Iterate_File_Upload @@ -2405,11 +2405,6 @@ <p style="text-align: center;"><strong style="font-size: 16px;">Business Information</strong></p> <p style="text-align: center;"><strong style="font-size: 16px;">Business Information</strong></p> DisplayText DisplayText BusinessAddressLabel <p><strong style="background-color: rgb(255, 255, 255); font-size: 12px; font-family: &quot;Proxima Nova&quot;; color: rgb(221, 53, 53);">*</strong><strong style="background-color: rgb(255, 255, 255); font-size: 12px; font-family: &quot;Proxima Nova&quot;; color: rgb(44, 172, 104);"> Business Address</strong></p> DisplayText Business_Name Business_Name String String @@ -2422,6 +2417,11 @@ LEN( {!Business_Name} )<= 120 LEN( {!Business_Name} )<= 120 BusinessAddressLabel <p><strong style="background-color: rgb(255, 255, 255); font-size: 12px; font-family: &quot;Proxima Nova&quot;; color: rgb(221, 53, 53);">*</strong><strong style="background-color: rgb(255, 255, 255); font-size: 12px; font-family: &quot;Proxima Nova&quot;; color: rgb(44, 172, 104);"> Business Address</strong></p> DisplayText STREET_ADDRESS STREET_ADDRESS String String 4 changes: 4 additions & 0 deletions4 force-app/main/default/lwc/communityFilesRelatedList/communityFilesRelatedList.css Viewed Original file line number Original file line Diff line number Diff line change @@ -3,6 +3,10 @@ margin-bottom: 10px; margin-bottom: 10px; } } .bgroundColor{ background-color: #f2f2f2; } .loan-card { .loan-card { background: #fff; background: #fff; border: 1px solid #d8dde6; border: 1px solid #d8dde6; 3 changes: 2 additions & 1 deletion3 force-app/main/default/lwc/communityFilesRelatedList/communityFilesRelatedList.html Viewed Original file line number Original file line Diff line number Diff line change @@ -1,4 +1,5 @@ --> -->